package com.wqr.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.wqr.dao.DiscussDao;
import com.wqr.pojo.Discuss;
import com.wqr.pojo.DiscussExample;

@Service
public class DiscussServiceImp implements DiscussService{
	@Autowired
	public DiscussDao discussDao;
	
	public List<Discuss> list() throws Exception {
		DiscussExample example = new DiscussExample();
		List<Discuss> list = discussDao.selectByExample(example);
		return list;
	}

	public int delectDiscuss(Integer discussId) throws Exception {
		int a = discussDao.deleteByPrimaryKey(discussId);
		if(a > 0) {
			return 1;
		}else {
			return 0;
		}
	}
	public int insertDiscuss(Discuss discuss) throws Exception {
		if(discussDao.insertSelective(discuss) > 0) {
			return 1;
		}else {
			return 0;
		}
	}
	public int updateDiscuss(Discuss discuss) throws Exception {
		int a = discussDao.updateByPrimaryKeySelective(discuss);
		if(a > 0) {
			return 1;
		}else {
			return 0;
		}
	}

	public Discuss selectByPrimaryKey(Integer discussId) throws Exception {
		Discuss list = discussDao.selectByPrimaryKey(discussId);
		return list;
	}

	public List<Discuss> selectDiscuss(Discuss discuss) throws Exception {
		List<Discuss> list = discussDao.selectByWhere(discuss);
		return list;
	}


}
